#ifndef MAP_READER_H
#define MAP_READER_H

#include <string>
#include <map>
#include <memory>
#include "tinyxml2.h"
#include "rclcpp/rclcpp.hpp"

using namespace tinyxml2;

struct MapPointData {
  MapPointData()
    : id(-1), x(0), y(0), angle(0), navType(-1), qrCodeId(-1) {}

  MapPointData(int id_, double x_, double y_, double angle_, int navType_, int qrCodeId_)
    : id(id_), x(x_), y(y_), angle(angle_), navType(navType_), qrCodeId(qrCodeId_) {}

  MapPointData(const MapPointData& data) {
    id = data.id;
    x = data.x;
    y = data.y;
    angle = data.angle;
    navType = data.navType;
    qrCodeId = data.qrCodeId;
  }

  int id;
  double x;
  double y;
  double angle;
  int navType;
  int qrCodeId;
};

class MapStreamReader : public rclcpp::Node {
public:
  MapStreamReader();
  bool load_map_xmlfile();
  std::map<int, MapPointData> pointsMap;

private:
  std::string FindMapId(XMLElement *root);
  XMLElement *FindMapData(XMLElement *root, const std::string &target_map_id);
  const std::string kMapPath = std::string(std::getenv("HOME")) + "/map/mapTest.xml";
  XMLElement *root;
  XMLElement *secondRoot;
  XMLElement *point_Node;
};

#endif // MAP_READER_H